package com.huwaiwai.web.controller;

import com.google.common.collect.Lists;
import com.huwaiwai.thread.task.TaskFunction;
import com.huwaiwai.thread.task.TaskRequest;
import com.huwaiwai.thread.thread.MyThreadPool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by huweiwei on 2017/4/10.
 */
@RestController
@RequestMapping("api")
public class Api {

    @Autowired
    private MyThreadPool myThreadPool;

    @GetMapping("/test01")
    public String test01(){

        List<TaskFunction> list = Lists.newArrayList(()-> 1 + 1, "test"::length, ()->"test".equals("test"));

        List result = myThreadPool.execute(new TaskRequest(list));

        return result.toString();
    }
}
